﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Ue.Components.VerificationCode
{
    public class VerifyCodeComponentElement<T>
    {
        private IEnumerable<T> accessories = null;

        public VerifyCodeComponentElement(IEnumerable<T> accessories)
        {
            if (accessories != null && accessories.Count() > 0)
            {
                this.accessories = accessories;
            }
        }

        public IEnumerable<T> Elements
        {
            get { return this.accessories; }
        }

        public T GetRandomElement()
        {
            return this.accessories.Count() == 0
                ? default(T)
                : this.Elements.ElementAt(VerifyCodeHolder.GetRandom(this.Elements.Count()));
        }
    }
}
